/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.rsocket.server;

import java.net.InetSocketAddress;

/**
 * 表示一个已完全配置的 RSocket 服务器的简单接口。
 * 允许通过 {@link #start()} 启动 和 {@link #stop()} 停止 服务器。
 *
 * @author Brian Clozel
 * @since 2.2.0
 */
public interface RSocketServer {

	/**
	 * 启动 RSocket 服务器。如果服务器已启动，则调用此方法无效。
	 * @throws RSocketServerException 如果服务器无法启动
	 */
	void start() throws RSocketServerException;

	/**
	 * 停止 RSocket 服务器。如果服务器已停止，则调用此方法无效。
	 * @throws RSocketServerException 如果服务器无法停止
	 */
	void stop() throws RSocketServerException;

	/**
	 * 返回服务器正在监听的地址。
	 * @return 地址
	 */
	InetSocketAddress address();

	/**
	 * RSocket 服务器的传输协议选择。
	 */
	enum Transport {

		/**
		 * TCP 传输协议。
		 */
		TCP,

		/**
		 * WebSocket 传输协议。
		 */
		WEBSOCKET

	}

}
